/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.rum.gui.component;

import cz.muni.fi.rum.domainmodel.ReflectorListener;
import cz.muni.fi.rum.gui.component.TreeModel.ReflectorNodeType;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author pmikulasek
 */
public final class ListenerNode extends ReflectorNode/*<ReflectorListener> */ implements Serializable, Cloneable {

    private static AtomicInteger count = new AtomicInteger();
    private static final String LISTENER = "Listener";
    private final String uniName;

    public ListenerNode() {
        super(ReflectorNodeType.listener, LISTENER + count.getAndIncrement());
        uniName = LISTENER + count.get();
    }

    @Override
    public String toString() {
        ReflectorListener list = (ReflectorListener) super.getContent();
        if (list == null) {
            return uniName;
        }
        Integer port = list.getPort();
        if (port == null) {
            return uniName;
        }
        StringBuilder buld = new StringBuilder();
//        buld.append(LISTENER);
//        buld.append("/");
        buld.append(list.getType());
        buld.append("/");
        buld.append(port);
        return buld.toString();
    }
}
